#include <iostream>
using namespace std;

class House
{
public:
	House() {}
	~House() {}
	void setFloor(string floor) {
		this->_floor = floor;
		return;
	}
	void setWal(string wall) {
		this->_wall = wall;
		return;
	}
	void setRoof(string roof) {
		this->_roof = roof;
		return;
	}
	void houseInfo()
	{
		cout << _floor <<"   "<<_wall<<"   "<<_roof << endl;
	}
private:
	string _floor;
	string _wall;
	string _roof;
};

class Builder
{
public:
	Builder() {
		this->_house = new House;

	}
	~Builder()
	{
		if (_house!=nullptr)
			{
				delete _house;
				_house = nullptr;
			}
	}
	virtual void buildFloor() = 0;
	virtual void buildWall() = 0;
	virtual void buildRoof() = 0;
	House* _house;
};

class BuilderA:public Builder
{
public:
	BuilderA(){}
	~BuilderA(){}
	void buildFloor() {
		this->_house->setFloor("builderA set floor");
	}
	void buildWall() {
		this->_house->setWal("buildA set wall");
	}
	void buildRoof() {
		this->_house->setRoof("buildA set roof");
	}
};

class BuilderB :public Builder
{
public:
	BuilderB() {}
	~BuilderB() {}
	void buildFloor() {
		this->_house->setFloor("builderB set floor");
	}
	void buildWall() {
		this->_house->setWal("builderB set wall");
	}
	void buildRoof() {
		this->_house->setRoof("builderB set roof");
	}
};

class Director
{
public:
	Director():_builder(nullptr){}
	~Director(){if (_builder!=nullptr)
	{
		delete _builder;
		_builder = nullptr;
	}
	}
	void setBuilder(Builder* builder)
	{
		this->_builder = builder;
	}
	House* construct()
	{
		this->_builder->buildFloor();
		this->_builder->buildRoof();
		this->_builder->buildWall();
		return this->_builder->_house;
	}
	Builder* _builder;
};






